evaluate right side first, then remember the result as the value on the left side
in case of fractions always round down


1) m.atk = primary stat + base power of spell + gear bonuses
	gear bonus:
		+2 magic weapon
		+3 magic armor
		+2 magic helm
		+1 Ancient Talisman
		+2 Crystal Ring
	base power:
		Lv1 spell: +25
			(-2 for each half level)
		Lv3 spell: +17
		boss spells may not hold to this rules


2) m.atk = m.atk * min(level + 38, 129)
this means level caps at 91 for spell damage purposes


3) m.atk = m.atk / 39


4) m.atk = m.atk + 1.5*level


5) if correct saber is present:
	m.atk = m.atk * 1.1


6) m.atk = m.atk + secondary stat * (62 + level) / 53 + gear bonus
	gear bonus:
		Muramasa: +death penalty/4


7) m.atk = m.atk * character factor
	1.0 for player
	0.9~1.3 depending on enemy type


8) damage = m.atk - relevant defense
	m.def in most cases
	p.def for Arrows, Darts, Jutsus, ...
	none for certain boss spells


9) if Manslaughter (Rogue) equipped:
	if RNG[0..127] > LUCK+3:
		damage x2


10) if Maul of the Dead (Necromancer) equipped:
	damage = damage + (maxHP - HP)/4


11) for single target spells and always-MT spells:
	damage = damage * 1.25


12) magic attack up/down buff on caster
	damage = damage * 1.25 for buff
	damage = damage * 0.75 for debuff
	no change if both or neither


13) magic defense up/down buff on target
	damage = damage * 0.75 for buff
	damage = damage * 1.25 for debuff
	no change if both or neither


14) damage = damage * (3 + spell power factor + gear bonus)
	gear bonus:
		Skeleton Mail: +2 for Lv2.5 or lower
		Skeleton Mail: +1 for Lv3
	base power:
		Lv1 spell: +4
			(+1 for each half level)
		Lv3 spell: +8


15) damage = damage / 7


16) physical resistance/weakness
	only for "physical" spells like Shuriken
	x1.50 damage for weakness
	x0.50 damage for resistance
	x0.25 damage for strong resistance
	x0.00 damage for immunity


17) elemental resistance/weakness
	x1.50 damage for weakness
	x0.50 damage for resistance [skipped for Lv2 spells with Rune Staff equipped]
	x0.00 damage for immunity
	invert damage for absorption
	change target of damage in case of reflection
		if reflected AND the original target had Platinum Armor: x1.75 damage
		otherwise do not change damage


18) element of spell matches element of day (at least partially)
	damage x1.25


19) difficulty factor
	varies by character and difficulty, compare to player/enemy strength in the README

20) damage degradation for targetting high level monster
	100% vs players
	100% vs enemies Lv1-10
	47.31% vs enemies Lv99


21-26) boss mechanics
	omitted because spoilers


27) cap at 999 damage